﻿/*
 * An implementation of an IMasterView. This view assigns it self with the main controller and will thus
 * work as a main input UI for controller the CA
 * Author: Anders Høst | ahkj@itu.dk
 * date: 13 dec 2010
 * */
using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace AutomaTones.View.GUI_View {
    public partial class Main : UserControl {
        private readonly Assembly _files;
        public Main() {
            InitializeComponent();
            // Gets all the embedded resources and collects them in this assembly.
            _files = Assembly.GetExecutingAssembly();
            play.Image = new Bitmap(_files.GetManifestResourceStream("AutomaTones.Graphics.PlayButton.png"));
            pause.Image = new Bitmap(_files.GetManifestResourceStream("AutomaTones.Graphics.PauseButton.png"));
            forwards.Image = new Bitmap(_files.GetManifestResourceStream("AutomaTones.Graphics.FastForward.png"));
            backwards.Image = new Bitmap(_files.GetManifestResourceStream("AutomaTones.Graphics.Backwards.png"));
            this.BackgroundImage = new Bitmap(_files.GetManifestResourceStream("AutomaTones.Graphics.main.png"));
        }

        public Action OnPlayButtonClickEvent { get;
            set;
        }

        public Action OnPauseButtonClickEvent { get;
            set;
        }

        public Action OnRewindButtonClickEvent { get;
            set;
        }

        public Action OnForwardButtonClickEvent { get; set; }

        public Action<int> OnVolumeChangeEvent {
            get;
            set;
        }

        private void VolumeChanged(object sender, EventArgs e){
            VScrollBar sc = (VScrollBar)sender;
            OnVolumeChangeEvent.Invoke(sc.Value);
        }

        private void forwardPicClick(object sender, MouseEventArgs e) {
            OnForwardButtonClickEvent.Invoke();
        }

        private void pausePicClick(object sender, MouseEventArgs e) {
            OnPauseButtonClickEvent.Invoke();
        }

        private void playPicclick(object sender, MouseEventArgs e)
        {
            OnPlayButtonClickEvent.Invoke();
        }

        private void back(object sender, MouseEventArgs e) {
            OnRewindButtonClickEvent.Invoke();
        }
    }
}
